<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page import="cn.uce.common.constants.AuthConstants"%>
<c:set var="ctx" value="${pageContext.request.contextPath}" />
<c:set var="jsTimer" value="<%=new Date().getTime()%>" />

<%-- 	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/styles/common/jquery-accordion-menu.css">
 --%>	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/styles/common/common-index.css">
	<link rel="icon" href="${pageContext.request.contextPath}/favicon.ico" type="image/x-icon" />
	<link rel="shortcut icon" href="${pageContext.request.contextPath}/favicon.ico" type="image/x-icon" />
	<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common/plugins/encryptionAlgorithm.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common/plugins/jquery-accordion-menu.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/scripts/common/plugins/vue-2.3.min.js"></script> --%>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/hg/hg.ui.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/hg/hg.util.js"></script>
	<script src="${pageContext.request.contextPath}/static/js/debugout.js?v=1.0.0" type="text/javascript" charset="utf-8"></script>
	<!-- 引入socketjs -->
	<%-- <script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ws/sockjs.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ws/stomp.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/static/js/ws/reconnecting-websocket.js"></script> --%>
	<!--覆盖样式-->
	<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/static/css/index-over.css">

<!--  全局 -->
<script>
var G_CTX_PATH = "${ctx}";
//文件最大上传大小
var HG_FILE_MAX_SIZE = 95*1024*1024;

function getParam(url) {
    var index = url.indexOf('?');
    var obj = {};
    if(!(index < 0)){
    	var datas = url.substring(index+1, url.length).split('&');
    	for (var item of datas) {
    	   var data = item.split('=')
    	   obj[data[0]] = data[1];
    	}
    }
    //return JSON.stringify(obj);  
    
    return obj;  
  }

/**
 * 
 * @param perssion 权限Code
 * @param title 页面标题
 * @param url URL
 */
function openTabCrossDomainCcSimple(perssion,titles,url,param1,param2,param3,param4){
	if(titles == null || titles == ' ' || titles == ''){
		titles = '';
	}
	
	//清洗URL参数
	var param = getParam(url);
	//清洗URL
	var index = url.indexOf('?');
	if(!(index < 0)){
		url = url.substring(0, index);
	}
	var http = '';
	if('https:' == document.location.protocol){
		http = 'https://';
	}else{
		http = 'http://';
	}
	var accessurl = http + window.location.host +'/cc-main'+ url;
    openTabCrossDomain(perssion,param,{title:titles,systemCode:'CC',url:accessurl});
}


/**
 * 在js中添加该方法
 * 关闭当前页面
 */
function closeCurrentTab(title) {
	if(crossDomainFlag == true){
		window.top.postMessage({fn:'closeTab',title:title}, '*');
	}else{
		window.parent.window.vm.closeCurrentTab(title);
		//window.top.vm.closeTabFromIFrame(title);
	}
}


/**
 * 在js中添加该方法
 * 关闭当前页面
 */
function beforeCloseCurrentTab(fn,title) {
	if(fn)
		(fn);
	closeCurrentTab(title);
}

/**
 * 在js中添加该方法
 * 关闭当前页面
 */
function beforeCloseCurrentTabForName(fn,title) {
    if(fn)
        (fn);
    if(crossDomainFlag == true){
        window.top.postMessage({fn:'closeTab',title:title}, '*');
    }else{
        window.parent.window.vm.closeTabforName(title);
    }
}


/**
 * confirm
 * @param msg 消息内容
 * @param fn 回调方法
 * @param args 回调方法参数
 * @param closable:true 去掉右上角X
 */
function confirmMsgIcs(msg, fnY,fnN, args, title,closable) {
    var	infoTitle = !title ? '确认操作' : title;
    var msg = "<p>"+msg+"</p>";
    $.messager.confirm(infoTitle, msg, function(r) {
        if (r) {
            fnY.apply(this, args);
        }else{
            fnN.apply(this, args);
        }
    });
    if(closable){
        $(".panel-tool-close").css("display","none");
    }

}

/**
 * 判断运单&工单号是否存在，如果存在则时间失效 置空，如果不存在则有效 不置空
 仲裁投诉：waybillNum code     querySTimeForCreate  queryETimeForCreate  querySTimeFortaskCTime queryETimeFortaskCTime
 仲裁申诉：waybillNumVague  acoCode  codeVague querySTimeForCreate  queryETimeForCreate querySTimeFortaskCTime queryETimeFortaskCTime 
 保险：code acoCode wayBillNum querySTimeFortaskCTime  queryETimeFortaskCTime
 客服服务：code waybillNumVague woCode querySTimeFortaskCTime  queryETimeFortaskCTime
 客户理赔：code waybillNum  querySTimeFortaskCTime  queryETimeFortaskCTime
 */
function timeFilter(data){
	var codes = "";
	//判断数据是否存在
	if(null != data && data){
		//运单号 waybillNum waybillNumVague
		if(data.waybillNum){
			codes += data.waybillNum;
		}
		if(data.wayBillNum){
			codes += data.wayBillNum;
		}
		if(data.waybillNumVague){
			codes += data.waybillNumVague;
		}
		//投诉工单号 code acoCode  保险工单号code 
		if(data.code){
			codes += data.code;
		}
		if(data.acoCode){
			codes += data.acoCode;
		}
		if(data.woCode){
			codes += data.woCode;
		}
		
		//申诉工单号codeVague 
		if(data.codeVague){
			codes += data.codeVague;
		}
		//开始、结束时间
		//1类：querySTimeForCreate  queryETimeForCreate
		//2类：querySTimeFortaskCTime queryETimeFortaskCTime
		codes  =  codes.replace(/\s+/g,""); //去空
		if(null != codes  && undefined != codes && "" != codes && " " != codes && 0 != codes.length){
			if(data.querySTimeForCreate){
				data.querySTimeForCreate=null;
			}
			if(data.queryETimeForCreate){
				data.queryETimeForCreate=null;
			}
			if(data.querySTimeFortaskCTime){
				data.querySTimeFortaskCTime=null;
			}
			if(data.queryETimeFortaskCTime){
				data.queryETimeFortaskCTime=null;
			}
		}
	}
}

/**
 * 判断运单&工单号是否存在，如果存在则时间失效 置空，如果不存在则有效 不置空
 仲裁投诉：waybillNum code     querySTimeForCreate  queryETimeForCreate  querySTimeFortaskCTime queryETimeFortaskCTime
 仲裁申诉：waybillNumVague  acoCode  codeVague querySTimeForCreate  queryETimeForCreate querySTimeFortaskCTime queryETimeFortaskCTime 
 保险：code acoCode wayBillNum querySTimeFortaskCTime  queryETimeFortaskCTime
 客服服务：code waybillNumVague woCode querySTimeFortaskCTime  queryETimeFortaskCTime
 客户理赔：code waybillNum  querySTimeFortaskCTime  queryETimeFortaskCTime
 */
function exportTimeFilter(data){
	var codes = "";
	//判断数据是否存在
	if(null != data && data){
		//运单号 waybillNum waybillNumVague
		if(data.waybillNum){
			codes += data.waybillNum;
		}
		if(data.wayBillNum){
			codes += data.wayBillNum;
		}
		if(data.waybillNumVague){
			codes += data.waybillNumVague;
		}
		//投诉工单号 code acoCode  保险工单号code 
		if(data.code){
			codes += data.code;
		}
		if(data.acoCode){
			codes += data.acoCode;
		}
		if(data.woCode){
			codes += data.woCode;
		}
		
		//申诉工单号codeVague 
		if(data.codeVague){
			codes += data.codeVague;
		}
		//开始、结束时间
		//1类：querySTimeForCreate  queryETimeForCreate
		//2类：querySTimeFortaskCTime queryETimeFortaskCTime
		codes  =  codes.replace(/\s+/g,""); //去空
		if(null != codes  && undefined != codes && "" != codes && " " != codes && 0 != codes.length){
			if(data.querySTimeForCreate){
			    $('#querySTimeForCreate').datebox('setValue', null);
				//data.querySTimeForCreate=null;
			}
			if(data.queryETimeForCreate){
			    $('#queryETimeForCreate').datebox('setValue', null);
				//data.queryETimeForCreate=null;
			}
			if(data.querySTimeFortaskCTime){
			    $('#querySTimeFortaskCTime').datebox('setValue', null);
				//data.querySTimeFortaskCTime=null;
			}
			if(data.queryETimeFortaskCTime){
			    $('#queryETimeFortaskCTime').datebox('setValue', null);
				//data.queryETimeFortaskCTime=null;
			}
		}
	}
}

/**
 * 获取上级网点名称
 * baseOrgCode 当前机构基础编码
 baseOrgCodeEleId 父级机构编码元素绑定ID
 baseOrgNameEleId 父级机构名称元素绑定ID
 */
function setComplaintsParentBranch(baseOrgCode,baseOrgCodeEleId,baseOrgNameEleId){
	if(!baseOrgCode){
		retrun;
	}
    //获取当前投诉人,投诉网点name,code
    var url =G_CTX_PATH+'/cs/omg/org/getParentOrgInforByCmsBaseOrgCode.do';
    uceAjax(url,{'baseOrgCode':baseOrgCode},function(data){
        // 0705 martin 新增所属机构
        if(null != data && "null" != data && "undefined" != data){
        	 if(baseOrgNameEleId){
            	 $('#' + baseOrgNameEleId).textbox('setValue',data.orgName);
            }
            if(baseOrgCodeEleId){
               $('#' + baseOrgCodeEleId).val(data.baseOrgCode);
           }	
        }
       
    });
}


/**
 * 获取上级网点名称
 * baseOrgCode 当前机构基础编码
 */
function getSingleComplaintsParentBranch(baseOrgCode){
	if(!baseOrgCode){
		return "";
	}
    //获取当前投诉人,投诉网点name,code
    var url =G_CTX_PATH+'/cs/omg/org/getParentOrgInforByCmsBaseOrgCode.do';
    uceAjax(url,{'baseOrgCode':baseOrgCode},function(data){
        console.log(data);
        // 0705 martin 新增所属机构
        if(null != data && "null" != data && "undefined" != data){
        	return data.orgName
        }
    });
}

//带入的是工单还是运单标识
var billType;

/**
 * 工单号
 */
function clearBillCodes1(){
    //$("#billCodes").val('');
    div1=document.getElementById('div1');
    div1.className = "tab-active";
    div1.style.backgroundColor='#dddddd';
    div2=document.getElementById('div2');
    $("#woCodes").attr("placeholder","请输入工单号");
    div2.className = "";

    div2.style.backgroundColor='#F5F5F5';
    billType = "";
    
    if(document.getElementById('div3')){
    	div3=document.getElementById('div3');
    	div3.className = "";
    	div3.style.backgroundColor='#F5F5F5';
    }
}

/**
 * 运单号
 */
function clearBillCodes2(){
    div2=document.getElementById('div2');
    div2.style.backgroundColor='#dddddd';
    div1.className = "";
    div1=document.getElementById('div1');
    div2.className = "tab-active";
    div1.style.backgroundColor='#F5F5F5';
    $("#woCodes").attr("placeholder","请输入运单号");
    billType = "1";
    
    if(document.getElementById('div3')){
    	div3=document.getElementById('div3');
    	div3.className = "";
    	div3.style.backgroundColor='#F5F5F5';
    }
}

/**
 * 投诉编号
 */
function clearBillCodes3(){
    div3=document.getElementById('div3');
    div3.style.backgroundColor='#dddddd';
    div3.className = "tab-active";
    $("#woCodes").attr("placeholder","请输入投诉编号");
    billType = "2";
    
    if(document.getElementById('div1')){
    	div1=document.getElementById('div1');
    	div1.className = "";
    	div1.style.backgroundColor='#F5F5F5';
    }
    
    if(document.getElementById('div2')){
    	div2=document.getElementById('div2');
    	div2.className = "";
    	div2.style.backgroundColor='#F5F5F5';
    }
}

/**
 * 清空单号
 */
function clearBillCodes(){
    $("#woCodes").val('');
}

/**
 * 页面加载时初始化
 */
function initDoubleCodeArea(){
	 div1.style.backgroundColor='#dddddd';
     document.getElementById('div1').className = "tab-active";
     $("#woCodes").attr("placeholder","请输入工单号");
     billType = "";
}

/**
 * 重置页面查询条件
 */
function resetQueryCondition(){
    div1=document.getElementById('div1');
    div1.className = "tab-active";
    div1.style.backgroundColor='#dddddd';
    div2=document.getElementById('div2');
    div2.className = "";
    div2.style.backgroundColor='#F5F5F5';
    $("#woCodes").attr("placeholder","请输入工单号");
    billType = "";
    
    if(document.getElementById('div3')){
    	div3=document.getElementById('div3');
    	div3.className = "";
    	div3.style.backgroundColor='#F5F5F5';
    }
}

/**
 * 表单提交前的验证（暂未用到）
 */
function queryValidate(){
	var flag = false;//是否为空
    if($("#woCodes").val() == '' || $("#woCodes").val() == null){
    	
    }else{
        var billCodes = $("#woCodes").val().replace(/[\r\n]/g,'');
        if(billCodes == '' || billCodes == null){
            flag = true;
        }
    }
    if($("#woCodes").val().split("\n").length > 200){
        showInfoMsg("最多查询200条数据！");
        return;
    }
}

/**
 * 跳转物流轨迹界面
 * @param perssion
 * @param titles
 * @param url
 * @param param1
 * @param param2
 * @param param3
 * @param param4
 */
function openTabCrossDomainForWlgj(perssion,titles,url,param1,param2,param3,param4){
    if(titles == null || titles == ' ' || titles == ''){
        titles = '';
    }
    debugger;
    //清洗URL参数
    var param = getParam(url);
    //清洗URL
    var index = url.indexOf('?');
    if(!(index < 0)){
        url = url.substring(0, index);
    }
    var accessurl =  url;
    // openTabCrossDomainForWlgj(perssion,param,{title:titles,systemCode:'ICS',url:accessurl});
    open(perssion,param,{title:titles,systemCode:'CC',url:accessurl});
}


function open(permissionCode,params,attr){
    var urlParams = '';
    if(params){
        for(key in params){
            urlParams += key+'='+params[key] + '&';
        }
    }
    if(attr && attr.url)
        window.top.vm.openwuliguijiTab(attr.title,attr.url +'?' + urlParams,true,null,attr.systemCode,attr && attr.refresh ? attr.refresh : undefined);
    // }}
}

</script>